<template>
  <div>
<!--    <div>-->
<!--    </div>-->
    <div class="log-panel">
      <div class="Initiate-container">
        <div class="refresh"></div>
      </div>
      <div>
          <el-table :data="pointLogList" stripe style="width: 100%">
            <el-table-column prop="id" :label="$t('记录id')" width="180"></el-table-column>
            <el-table-column prop="description" :label="$t('说明')" width="180"></el-table-column>
            <el-table-column prop="imei" label="IMEI"></el-table-column>
            <el-table-column prop="serviceName" :label="$t('服务名称')"></el-table-column>
            <el-table-column prop="pointNums" :label="$t('变更金额')"></el-table-column>
            <el-table-column prop="totalPoints" :label="$t('剩余金额')"></el-table-column>
            <el-table-column prop="createTime" :label="$t('创建时间')"></el-table-column>
          </el-table>
        <div class="block">
          <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[10, 20, 50, 200]"
              :page-size="pageSize"
              :total="total"
              layout="prev, slot, next, jumper, sizes"
              style="text-align: center">
            <span>{{ currentPage }}</span>
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import apiService from "@/api/apiService";

export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: "PointsLog",
  data() {
    return {
      orderWorkList: [],
      tableData: [],
      pageSize: 10,
      total: 0,
      currentPage: 1,
      pointLogList: [],
      searchRequest: {},
    }
  },
  watch: {

  },
  mounted() {
    // this.getService()
    this.initSearchRequest()
    // this.initOrderByList();
    this.initOrderList();
  },
  methods: {
    /* eslint-disable */
    tableRowClassName({row, rowIndex}) {
      if (rowIndex === 1) {
        return 'warning-row';
      } else if (rowIndex === 3) {
        return 'success-row';
      }
      return '';
    },
    handleSizeChange(val) {
      this.currentPage = 1
      this.pageSize = val
      this.searchRequest.page = this.currentPage;
      this.searchRequest.pageSize = val;
      this.doSearch(this.searchRequest)
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.searchRequest.page = val
      this.doSearch(this.searchRequest)
    },
    doSearch(params) {
      /* 不管是从哪发生的调用, 先把请求存起来, 这样翻页的时候能拿到之前的请求去查询 */
      this.searchRequest = params
      console.log(this.searchRequest.page)
      this.$nextTick(function () {
        apiService.post("/point-log", this.searchRequest).then(res => {

          this.pointLogList = res.data.dataList
          this.total = res.data.total
        })
      })
    },
    initSearchRequest() {
      this.searchRequest.page = 1
      this.searchRequest.pageSize = this.pageSize
    },
    initOrderList() {
      this.doSearch(this.searchRequest)
    }
  }
};
</script>

<style lang="scss" scoped>
.log-panel {
  box-shadow: 0 0 0 .2rem #00000005;
  border-radius: 10px;
  border: solid white 1px;
  background: rgb(255, 255, 255);
  margin: auto;
  width: 95%;
}


.order-container{
  display: flex;
  flex-wrap: nowrap;
  gap: 20px;
}

.Initiate{
  background: #3560ee;
  color: white;
  font-size: 15px;
  font-weight: bolder;
}

.Initiate-container{
  height: 40px;
  box-shadow: 0 0 0 .2rem #00000005;
  border-radius: 10px;
  border: solid white 1px;
  background: rgb(255, 255, 255);
  margin: auto;
  width: 95%;
  text-align: left;
  padding: 10px 10px 10px 10px;
}

.refresh{
  border-radius: 50%;
  background-image: url('@/assets/refresh.svg');
  background-size: contain;
  float: right;
  margin-top: 10px;
  margin-right: 10px;
  width: 20px;
  height: 20px;
}

.refresh:hover{
  background-color: #cccccc;
  cursor: pointer;
}

.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}

</style>
